/*
 * @Author: C.
 * @Date: 2023-02-02 13:14:40
 */
import { dateUtil } from '/@/utils/dateUtil';
import { isNullOrUnDef } from '/@/utils/is';
import { projectSettings } from '../../settings/projectSettings';
const { dataPlaceholder, dateFormat, timeFormat } = projectSettings;
import {
  handleEmpty,
  amountFormat,
  handleImg,
  handleLink,
  handleState,
  handleTag,
  handleBoolean,
} from '../../utils/data/transform';
export type FilterEnums =
  | 'time'
  | 'date'
  | 'default'
  | 'amount'
  | 'image'
  | 'link'
  | 'state'
  | 'tag'
  | 'boolean';
type IFilter = {
  [key in FilterEnums]: {
    func: Fn;
  };
};
export const filterMap: IFilter = {
  time: {
    func: ({ text }) => (isNullOrUnDef(text) ? dataPlaceholder : dateUtil(text).format(timeFormat)),
  },
  date: {
    func: ({ text }) => (isNullOrUnDef(text) ? dataPlaceholder : dateUtil(text).format(dateFormat)),
  },
  default: {
    func: handleEmpty,
  },
  amount: {
    func: amountFormat,
  },
  image: {
    func: handleImg,
  },
  link: {
    func: handleLink,
  },
  state: {
    func: handleState,
  },
  tag: {
    func: handleTag,
  },
  boolean: {
    func: handleBoolean,
  },
};
